<?php
if(!isset($intergrated))
{
header('Content-Type: text/xml');
header('Cache-control: no-cache');
}

include_once("../store/other/util/functs.php");
include_once("../store/other/util/util.php");


//load database information
$db_info = get_database_info();

$link = mysql_connect($db_info['db_server'], 'root', $db_info['db_password']); //right now we are hardcoded..
if (!$link) 
{
   die('Could not connect: ' . mysql_error());
}

mysql_select_db($db_info["db_name"]);

$property_name = $_GET['propertyName'];
$data_id = $_GET['dataId'];
$value = $_GET['value'];
$add_remove = $_GET['add_remove'];
databinding_updater($property_name, $data_id, $value, $add_remove);

$funct_name = $_GET['funct_name'];
$input_data = $_GET;
$input_vars = load_input_vars_from_data($input_data);
$output_vars = NULL;
//input some standard sys variables
$input_vars['sys']['link'] = $link;
$input_vars['sys']['intergrated'] = $intergrated;

// if Button276_onClick is called
if ($funct_name == "Button276_onClick")
{
$output_vars = Button276_onClick ($input_vars);
}
$just_loaded = false;
if (!isset($funct_name) ||$funct_name == "")
{
$just_loaded = true;
$output_vars = page_on_load ($input_vars);
}
$output_vars['sys']['link'] = NULL;
$php_return_data = echo_differences_of($input_vars, $output_vars, $just_loaded);
if(!$intergrated)
{
echo $php_return_data;
}
mysql_close($link);
// Handling the onLoad of Page0 
function Page0_onLoad ($args)
{
$temp_var0 = funct_get_today(array(), $args['sys']);
$args['page']['date1'] = $temp_var0[0];
$temp_var0 = funct_set_month( array($args['page']['date1'], "Jan"), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date1'] = $temp_var0[0];
$temp_var0 = funct_set_day( array($args['page']['date1'],  2 ), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date1'] = $temp_var0[0];
$temp_var0 = funct_set_year( array($args['page']['date1'],  2003 ), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date1'] = $temp_var0[0];
if($args['page']['date2'] == "")
{
$temp_var0 = funct_get_today(array(), $args['sys']);
$args['page']['date2'] = $temp_var0[0];

}
$temp_var0 = funct_get_year( array($args['page']['date1']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['year1'] = $temp_var0[0];
$temp_var0 = funct_get_month( array($args['page']['date1']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['month1'] = $temp_var0[0];
$temp_var0 = funct_get_day( array($args['page']['date1']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['day1'] = $temp_var0[0];
$temp_var0 = funct_get_year( array($args['page']['date2']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['year2'] = $temp_var0[0];
$temp_var0 = funct_get_month( array($args['page']['date2']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['month2'] = $temp_var0[0];
$temp_var0 = funct_get_day( array($args['page']['date2']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['day2'] = $temp_var0[0];
$args['page']['label1'] = $args['page']['label2'] = " ";
$args['page']['x'] =  0 ;
$args['page']['img_url'] = "../store/images/semf.gif";
$args['page']['text'] = "Client Difference";
return $args;

} // end of the function Page0_onLoad

// Handling the onClick of Button276 
function Button276_onClick ($args)
{
$temp_var0 = funct_set_year( array($args['page']['date1'], $args['page']['year1']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date1'] = $temp_var0[0];
$temp_var0 = funct_set_month( array($args['page']['date1'], $args['page']['month1']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date1'] = $temp_var0[0];
$temp_var0 = funct_set_day( array($args['page']['date1'], $args['page']['day1']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date1'] = $temp_var0[0];
$temp_var0 = funct_set_year( array($args['page']['date2'], $args['page']['year2']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date2'] = $temp_var0[0];
$temp_var0 = funct_set_month( array($args['page']['date2'], $args['page']['month2']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date2'] = $temp_var0[0];
$temp_var0 = funct_set_day( array($args['page']['date2'], $args['page']['day2']), $args['sys']);
$args['sys'] = $temp_var0[1];
$args['page']['date2'] = $temp_var0[0];
$temp_var0 = funct_compare_dates( array($args['page']['date1'], $args['page']['date2']), $args['sys']);
$args['sys'] = $temp_var0[1];
$temp_var2 = funct_compare_dates( array($args['page']['date1'], $args['page']['date2']), $args['sys']);
$args['sys'] = $temp_var2[1];
if($temp_var0[0] >  0 )
{
$temp_var1 = funct_set_year( array($args['page']['date2'], $args['page']['year2']), $args['sys']);
$args['sys'] = $temp_var1[1];
$args['page']['date2'] = $temp_var1[0];
$args['page']['label1'] = $args['page']['label2'] = "Date1 is greater than Date2";

}
else if($temp_var2[0] <  0 )
{
$args['page']['label1'] = $args['page']['label2'] = "Date1 is Lesser than Date2";

}
else {
$args['page']['label1'] = $args['page']['label2'] = "Date1 is Equal to Date2";

}
$query = "SELECT player.id  FROM RepeaterTest_Player player ";
$result = mysql_query($query) or die ("Error in query: $query ".mysql_error()); 
	$args['table']['player'] = array(); //initializing appropriately
	// see if any rows were returned
	if (mysql_num_rows($result) > 0) 
	{
		while($row = mysql_fetch_row($result)) 
		{
			// set the text
			$id = $row[0]; // this will give an id
			$args['table']['player'][$id] = array("id" => $id);
		}
	} 
$args['page']['x'] = $args['page']['x'] +  1 ;
return $args;

} // end of the function Button276_onClick

// Handling the common page_on_load function 
function page_on_load ($input_vars) 
{
// call function for Page0 
$output_vars = Page0_onLoad ($input_vars);
$input_vars = $output_vars; //now input will be last outputs;)
$output_vars["table"] = 
       update_databound_properties(NULL, $input_vars, 1);
return $output_vars;

} // end of the function page_on_load

// the following function will be called by util.php
// to update the values of databound properties
function update_databound_properties($diff_vars, $args, $starter)
{

$table_vars = $args['table'];

return $table_vars;
}
//finally the function for databinding_updater..
//responsible for update the databound properties
function databinding_updater($property_name, $data_id, $value, $add_remove)
{
if($property_name == NULL)
{
 return;
}

$update_query = NULL;


if($update_query != NULL)
{
 $result = mysql_query($update_query) or die ("Error in query: $update_query ".mysql_error());
}
}

?>
